import type { Datum, EnterpriseDetail, EnterpriseListData, EnterpriseListParams, EnterpriseParams, EnterprisePut, Industry, RentBuilding, RentParams } from "@/types/enterprise";
import service, { request } from "@/utils/reuqest";


export const getEnterpriseListAPI = (params:EnterpriseListParams)=>{
  return request<EnterpriseListData>('/park/enterprise','GET',params)
}

export const getIndustryListAPI = ()=>{
  return request<Industry[]>('/park/industry','GET')
}

export const createEnterpriseAPI = (data:EnterpriseParams)=>{
  return request('/park/enterprise','POST',data)
}

export const getEnterpriseDetailAPI = (id:string)=>{
  return request<EnterpriseDetail>(`/park/enterprise/${id}`)
}

export const updateEnterpriseAPI = (data:EnterprisePut)=>{
  return request('/park/enterprise','PUT',data)
}

export const delEnterpriseAPI = (id:string)=>{
  return request(`/park/enterprise/${id}`,'DELETE')
}

export const getRentBuildListAPI = ()=>{
  return request<RentBuilding[]>('/park/rent/building')
}

export const  createRentAPI = (data: RentParams) => {
  return request('/park/enterprise/rent', 'POST', data)
}

export const getRentListAPI = (id: number)=>{
  return request<Datum[]>(`/park/enterprise/rent/${id}`)
}

export const outRentAPI = (rentId: string)=> {
  return request(`/park/enterprise/rent/${rentId}`, 'PUT')
}

export const deleteRentAPI = (rentId: string)=>{
  return request(`/park/enterprise/rent/${rentId}`,'DELETE')
}


export const downloadContract = (id: number)=>{
  return service.request<null, Blob>({
    method: 'GET',
    url: `/download/${id}`,
    responseType: 'blob'
  })
}


